﻿namespace Attacher
{
	using System;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;

	using Attacher.HotKeys;
	using Attacher.VisualStudio;

	using Microsoft.Practices.Unity;

	internal class RegistrationService : IRegistrationService
	{
		#region Attributes

		private readonly IUnityContainer container;

		#endregion

		#region Public Methods

		public RegistrationService(IUnityContainer container)
		{
			ParameterChecker.IsNotNull(container, "container");

			this.container = container;
		}

		public void Register()
		{
			this.container.RegisterType<IHotKeyService, HotKeyService>(new ContainerControlledLifetimeManager());
			this.container.RegisterType<IAttacherAutoStartService, AttacherAutoStartService>(new ContainerControlledLifetimeManager());
			this.container.RegisterType<IAttacherService, AttacherService>(new ContainerControlledLifetimeManager());
			this.container.RegisterType<IAutoStartService, AutoStartService>();
			this.container.RegisterType<IMainWindowViewModelFactory, MainWindowViewModelFactory>();
			this.container.RegisterType<IMainWindowViewModelInitializer, MainWindowViewModelInitializer>();
			this.container.RegisterType<IAttacherIconFactory, AttacherIconFactory>();
			this.container.RegisterType<IDictionary<HotKey, Action>, Dictionary<HotKey, Action>>(new InjectionConstructor());
		    this.container.RegisterType<IVisualStudioInstanceService, VisualStudioInstanceService>();
            this.container.RegisterType<ISelectInstanceWindowViewModelFactory, SelectInstanceWindowViewModelFactory>();
            this.container.RegisterType<ObservableCollection<VisualStudioInstanceViewModel>, ObservableCollection<VisualStudioInstanceViewModel>>(new InjectionConstructor());
		    this.container.RegisterType<IExceptionReportingServicesRegistrar, ExceptionReportingServicesRegistrar>();
		}

		#endregion
	}
}
